blob: f0f6fa89f33339385a6df92cd90a594a8244bf4e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import { productMap } from '../../../models/db';
import type { APIContext } from 'astro';
export function GET({ params }: APIContext) {
const id = Number(params.id);
if (productMap.has(id)) {
const product = productMap.get(id);
return new Response(JSON.stringify(product));
} else {
return new Response(null, {
status: 400,
statusText: 'Not found',
});
}
}
|